<template>
	<view>
		<template v-if="hashtagType == 1">
			<template v-if="list">
				<list-default
					:style="'order:'+list.order+';'"
					:item="list"></list-default>
			</template>
		</template>
		<template v-else>
			<youransns-diy
				:youransnsConfig="youransnsDiyData"
				v-if="youransnsDiyStatus"></youransns-diy>
		</template>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				hid: "",
				list: null,
				hashtagType:1,
				youransnsDiyData:null,
				youransnsDiyStatus:false
			}
		},
		onLoad(e) {
			this.hid = decodeURIComponent(e.hid);
			uni.setNavigationBarTitle({title: this.hid});
			this.getHashtagDIY();
		},
		methods: {
			getHashtagDIY(){
				uni.request({
					url:`${this.$_configFile()}hashtag.json`,
					method:"GET",
					success: (res) => {
						if(res.data.diy.length){
							this.hashtagType = 2;
							let url = res.data.diy.find(item => item.htid === this.hid)?.template;
							if(url){
								uni.request({
									url:`${this.$_configFile()}${url}`,
									method:"GET",
									success: (ref) => {
										this.youransnsDiyData = ref.data;
										this.$nextTick(() => {
											this.youransnsDiyStatus = true;
										});
									}
								})
							}else{
								this.hashtagType = 1;
								this.list = {
									"order": 0,
									"page": true,
									"query": {
										"hashtags": this.hid,
										"pageSize": 15
									},
									"randomInsertion": {
										"status": false,
										"html": "<p>广告呀</p>"
									}
								}
							}
						}else{
							this.hashtagType = 1;
							this.list = {
								"order": 0,
								"page": true,
								"query": {
									"hashtags": this.hid,
									"pageSize": 15
								},
								"randomInsertion": {
									"status": false,
									"html": "<p>广告呀</p>"
								}
							}
						}
					}
				})
			},
		},
		// 上拉加载事件
		onReachBottom() {
			uni.$emit('onReachBottom')
		}
	}
</script>

<style>

</style>